<template>
  <div>
    <el-form ref="myForm" :model="formData" :rules="rules">
      <el-form-item label="姓名" prop="name">
        <el-input v-model="formData.name"></el-input>
      </el-form-item>
      <el-form-item label="季度" prop="time">
        <MyQuarterSelector v-model="formData.time"></MyQuarterSelector>
      </el-form-item>
    </el-form>
    <el-button @click="handleSubmit">提交</el-button>
  </div>
</template>

<script>
import MyQuarterSelector from "@/view/quarterSelector/components/QuarterSelector.vue";

export default {
  name: "QuarterSelector",
  components: {MyQuarterSelector},
  data() {
    return {
      formData: {
        name: '',
        time: []
      },
      rules: {
        name: [{required: true, message: '姓名必填', trigger: 'change'}],
        time: [{required: true, message: '季度必填', trigger: 'change'}]
      }
    }
  },
  methods: {
    handleSubmit() {
      this.$refs.myForm.validate((valid) => {
        if (valid) {
          this.$message.success('新增成功')
        } else {
          this.$message.warning('请检查必填项')
        }
      })
    }
  }
}
</script>

<style scoped lang="less">

</style>
